const getters = {
  sidebar: state => state.app.sidebar,
  size: state => state.app.size,
  device: state => state.app.device,
  visitedViews: state => state.tagsView.visitedViews,
  cachedViews: state => state.tagsView.cachedViews,
  screenData: state => {
    const screenData = localStorage.getItem('screenData')
    if (screenData) {
      state.device.screen = screenData
    }
    return state.device.screen
  },
  fileData: state => {
    const fileData = localStorage.getItem('fileData')
    if (fileData) {
      state.device.file = fileData
    }
    return state.device.file
  },
  // 获取用户token
  token: state => {
    const token = localStorage.getItem('token')
    if (token) {
      state.user.token = token
    }
    return state.user.token
  },
  // 获取用户头像
  avatar: state => {
    // const avatar = localStorage.getItem('avatar')
    // if (avatar) {
    //   state.user.avatar = avatar
    // }
    return state.user.avatar
  },
  // 获取登录名称
  name: state => {
    // const name = localStorage.getItem('name')
    // if (name) {
    //   state.user.name = name
    // }
    return state.user.name
  },
  // 获取登录昵称
  nickname: state => {
    // const nickname = localStorage.getItem('nickname')
    // if (nickname) {
    //   state.user.nickname = nickname
    // }
    return state.user.nickname
  },
  // 获取用户邮箱
  email: state => {
    // const email = localStorage.getItem('email')
    // if (email) {
    //   state.user.email = email
    // }
    return state.user.email
  },
  // 获取手机号 
  phone: state => {
    // const phone = localStorage.getItem('phone')
    // if (phone) {
    //   state.user.phone = phone
    // }
    return state.user.phone
  },
  // 获取用户描述信息
  introduction: state => {
    const introduction = localStorage.getItem('introduction')
    if (introduction) {
      state.user.introduction = introduction
    }
    return state.user.introduction
  },
  // 获取用户角色
  roles: state => {
    const roles = localStorage.getItem('roles')
    if (roles) {
      state.user.roles = roles
    }
    return state.user.roles
  },
  // 获取导航权限
  permission_routes: state => {
    if (state.permission.menulist.length === 0) {
      const menus = localStorage.getItem('menulist')
      if (menus) {
        state.permission.menulist = JSON.parse(menus)
      }
    }
    return state.permission.menulist
  },
  // 获取二级权限
  role_permission: state => {
    if (state.permission.rolelist.length === 0) {
      const rolelist = localStorage.getItem('rolelist')
      if (rolelist) {
        state.permission.rolelist = JSON.parse(rolelist)
      }
    }
    return state.permission.rolelist
  },
  // 获取用户权限
  permissionlist: state => {
    // console.log('getter permissionlist---------',state.permission.permissionlist)
    if (state.permission.permissionlist&&state.permission.permissionlist.length === 0) {
      const permissionlist = localStorage.getItem('permissionlist')
      if (permissionlist) {
        state.permission.permissionlist = JSON.parse(permissionlist)
      }
    }
    return state.permission.permissionlist
  },
  errorLogs: state => state.errorLog.logs
}
export default getters
